
import zipfile


def fetch_hascode_from_file_name(file_name):
    if not "VirusShare" in file_name:
        return None

    start = file_name.find("_")
    if start < 1:
        return ""

    return file_name[start + 1:]

archive = zipfile.ZipFile('D:\malwares\VirusShare_00000.zip', 'r')

destination_path = "destination/malware_hascode/"

index = 0
file_name = 0
for malware_file_name in archive.filelist:
    print(malware_file_name.filename)

    if index == 500:
        index = 0
        file_name = file_name + 1

    if index == 0:
        hascode_file = open("destination/malware_hascode/" + str(file_name), "w")

    hascode = fetch_hascode_from_file_name(malware_file_name.filename)
    hascode_file.write(hascode + "\n")

    index = index + 1